let obj = {
  list: [{
    id: new Date().getTime(),
    title: '写作业',
    isDone: false
  }]
}

function reducer(state = obj, actions) {
  switch (actions.type) {
    case 'ADD_LIST':
      state.list.push({
        id: new Date().getTime(),
        title: actions.val,
        isDone: false
      })
      break;
    case 'EDIT_LIST':
      state.list.forEach((item) => {
        if (item.id === actions.val.id) {
          item.title = actions.val.title
        }
      })
      break;
    case 'DEL_LIST':
      state.list.forEach((item, i) => {
        if (item.id === actions.val) {
          state.list.splice(i, 1)
        }
      });
      break;
    case 'IS_DONE':
      state.list.forEach((item) => {
        if (item.id === actions.val.id) {
          item.isDone = actions.val.isDone;
        }
      })
      break;
    default:

  }
  return JSON.parse(JSON.stringify(state));

}
export default reducer;